<?php
class UserModel extends Model{
	protected $_validate = array(
		array('username','require','用户名必须填写！',0,'',3),
		array('username','','用户名已存在！',0,'unique',3),
		array('username','regname','用户名必须以a~z字母组成！',0,'',3),
		array('email','email','邮箱格式不合法！',0,'',3),
		array('phone','require','手机号必须填写！',0,'',3),
		array('phone','phone','手机号码不合法！',0,'',3),
	);
	
	protected $_auto = array(
		array('reg_time','getDate','','callback'),
		array('lastmodifytime','getDate',3,'callback'),
		array('password','md5',3,'function'),
	);
	
	function getDate(){
		return date('Y-m-d H:i:s');
	}
	
	/*
	 * 密码重置
	 */
	public function resetPsw($username){
		$user = D('User');
		$userdata['password'] = md5("httptest");
		$result = $user->where("username='$username'")->save($userdata);
		if($result >= 0){
			return true;
		}else{
			return false;
		}
	}
}